<%--
  Created by IntelliJ IDEA.
  User: asus
  Date: 2023/4/24
  Time: 10:02
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title></title>
    <link href="CSS/Style1.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="Scripts/jquery-3.1.1.js"></script>
    <script>
        $(function () {
            $("[name='deleteur']").click(function () {
                let thisa = $(this);
                let id = $(this).prop("id");
                $.ajax({
                    url:'delteByuserId?id='+id,
                    success:function (data) {
                        if(data==1){//删除成功
                            thisa.parent().parent().remove();
                        }
                    }
                })
            })
        })
    </script>
</head>
<body>
<div id="desDiv">
    <span>用户管理</span><br />
    管理系统中所有的用户
</div>
<div id="dataDiv">
    <table class="dataTable" style="width:50%;text-align: center;">
        <tr>
            <th>编号</th>
            <th>用户名</th>
            <th>真实姓名</th>
            <th>操作</th>
        </tr>
        <c:forEach items="${crmUsers}" var="user" >
            <tr>
                <td>${user.userid}</td>
                <td>${user.username}</td>
                <td>${user.realname}</td>
                <td>
                    <a href="queryCrmUserById?id=${user.userid}">修改</a>
                    <a href="#" name="deleteur" id="${user.userid}" >删除</a>
                </td>
            </tr>
        </c:forEach>
<%--        <tr>--%>
<%--            <td>2</td>--%>
<%--            <td>abc</td>--%>
<%--            <td>张三</td>--%>
<%--            <td>--%>
<%--                <a href="userUpdate.html">修改</a>--%>
<%--                <a href="#">删除</a>--%>
<%--            </td>--%>
<%--        </tr>--%>
<%--        <tr>--%>
<%--            <td>3</td>--%>
<%--            <td>abc</td>--%>
<%--            <td>张三</td>--%>
<%--            <td>--%>
<%--                <a href="userUpdate.html">修改</a>--%>
<%--                <a href="#">删除</a>--%>
<%--            </td>--%>
<%--        </tr>--%>
    </table>
</div>

<div id="dataDiv">
    <form action="addUserAndRole" method="post">
    <table class="tableEdit" style="width:50%;">
        <thead>
        <tr>
            <td colspan="2">添加用户</td>
        </tr>
        </thead>
        <tr>
            <td>用户名：</td>
            <td>
                <input type="text" name="username" value=""/>
            </td>
        </tr>
        <tr>
            <td>真实姓名：</td>
            <td>
                <input type="text" name="rname" value=""/>
            </td>
        </tr>
        <tr>
            <td>角色：</td>
            <td>
                <c:forEach items="${rolesList}" var="role">
                    <input type="checkbox" name="rdesc${role.rid}" value="${role.rname}"/>${role.rname}
                </c:forEach>
<%--                <input type="checkbox" name="rdesc2" value="销售主系统管理员管"/>销售主管--%>
<%--                <input type="checkbox" name="rdesc3" value="销售专员"/>销售专员--%>
            </td>
        </tr>
        <tfoot>
        <tr>
            <td colspan="2">
                <input type="submit" value="确定"/>&nbsp;&nbsp;
                <input type="button" value="关闭" onclick="window.close()" />
            </td>
        </tr>
        </tfoot>
    </table>
    </form>
</div>
</body>
</html>